@extends('wechat.member-layout')

@section('head')
    <script>
        jsload=0;
        done=0;
        function jsqrcode_loaded () {
            jsload=1;
            if (done==1) {
                var event = document.createEvent('HTMLEvents');
                event.initEvent("load", true, true);
                document.getElementById('qr').dispatchEvent(event);
            }
        }
        function decodeQR(e) {
            done=1;
            if (jsload) {
                qrcode.callback = function  (res) {
                    if (res&&/^http/.test(res)) {
                        document.getElementById('short_url').style.display='block';
                        var a=document.querySelector('#short_url a');
                        a.innerHTML=res;
                        a.href=res;
                    }else{
                        var script = document.createElement("script");
                        script.type = "text/javascript";
                        // callback('http://t.cn/R0s7YMb') 短网址
                        script.src = "./index.php?i=10&c=entry&id=565&type=2&do=surl&m=czt_tushang";
                        document.getElementsByTagName("head")[0].appendChild(script);
                    }
                };
                qrcode.decode(e);
            }
        }
    </script>
@endsection

@section('content')
    <div class="container" id="container">
        <div class="bd">
            <article class="weui_article">
                <a href="javascript:;" class="weui_btn weui_btn_plain_primary">打赏图已生成，长按图片保存</a>
                <p><img id="qr" onload="decodeQR(this)" src="/images/my-video-review.jpg" width="100%"></p>
                <div id="short_url" style="display: none;font-size: 18px;">
                    短连接：<a href=""></a>
                    <br/>
                    <p style="text-align: center;font-size: 14px;">（长按链接可拷贝或复制）</p>
                </div>
            </article>
        </div>
    </div>
@endsection


@section('js')
    <script>
        function callback (res) {
            if (res&&/^http/.test(res)) {
                document.getElementById('short_url').style.display='block';
                var a=document.querySelector('#short_url a');
                a.innerHTML=res;
                a.href=res;
            }
        }
    </script>
    <script onload="jsqrcode_loaded()" type="text/javascript" src="http://{{ env('QINIU_DOMAIN') }}/js/jsqrcode.js"></script>
@endsection
